package com.chujian.Activities;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import cn.jpush.android.api.InstrumentedActivity;
import cn.jpush.android.api.JPushInterface;
import cn.smssdk.SMSSDK;

import com.chujian.Global.Global;
import com.chujian.jpush.JpushUtil;
import com.chujian.orderingsystem.R;

public class MainConsumerActivity extends Activity {
//	sms sdk 
	 TextView tv;
	public static boolean isForeground = false;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activiy_main_consumer);
//		初始化mob sms sdk 
//		SMSSDK.initSDK(this, APPKEY, APPSECRET);
//		
//		 JPushInterface.setDebugMode(true); 	// 设置开启日志,发布时请关闭日志
//         JPushInterface.init(this);
//         tv=(TextView) findViewById(R.id.tv_main);
		try {
			Intent intent = getIntent();
			if (intent != null) {
//				Bundle bundle = intent.getExtras();
//				String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
//				String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
				String message=intent.getStringExtra("msg");
				tv.setText(message);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//         registerMessageReceiver();
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		isForeground = true;
	}
	@Override
	protected void onPause() {
		isForeground = false;
		super.onPause();
	}


	@Override
	protected void onDestroy() {
//		unregisterReceiver(mMessageReceiver);
		super.onDestroy();
	}
	
	
	public void doClick(View v){
		switch (v.getId()) {
		case R.id.btn_go:
			Intent intent=new Intent(MainConsumerActivity.this, LoginActivity.class);
			startActivity(intent);;
			break;
			
		case R.id.take_order:
			Intent intent2=new Intent(MainConsumerActivity.this, TableSelectActivity.class);
			startActivity(intent2);;
			break;
//		case R.id.table_manage:
//			Intent intent3=new Intent(MainConsumerActivity.this, TableListActivity.class);
//			startActivity(intent3);;
//			break;
		case R.id.food_categary:
			Intent intent4=new Intent(MainConsumerActivity.this, FoodCategaryActivity.class);
			startActivity(intent4);;
			break;	
		case R.id.order_manager_current:
			Intent intent5=new Intent(MainConsumerActivity.this, OrderCurrentListActivity.class);
			startActivity(intent5);;
			break;	
		case R.id.order_manager_current_consumer:
			Intent intent6=new Intent(MainConsumerActivity.this, OrderCurrentListActivityConsumer.class);
			startActivity(intent6);;
			break;	
			
//		case R.id.order_manager_history:
//			Intent intent7=new Intent(MainConsumerActivity.this, OrderHistoryListSellerActivity.class);
//			startActivity(intent7);;
//			break;	
		case R.id.order_manager_history_consumer:
			Intent intent8=new Intent(MainConsumerActivity.this, OrderHistoryListConsumerActivity.class);
			startActivity(intent8);;
			break;	
		case R.id.book_seat:
			Intent intent9=new Intent(MainConsumerActivity.this, BookSeatActivity.class);
			startActivity(intent9);;
			break;
//		case R.id.book_list_seller:
//			Intent intent10=new Intent(MainConsumerActivity.this, BookListSellerActivity.class);
//			startActivity(intent10);;
//			break;
		case R.id.notification_list:
			Intent intent11=new Intent(MainConsumerActivity.this, NotificationListActivity.class);
			startActivity(intent11);;
			break;
		case R.id.user_info_complete:
			Intent intent12=new Intent(MainConsumerActivity.this, UserInfoCompleteActivity.class);
			startActivity(intent12);;
			break;
//		case R.id.income:
//			Intent intent13=new Intent(MainConsumerActivity.this, IncomeActivity.class);
//			startActivity(intent13);;
//			break;
		default:
			break;
		}
	}
	
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if(keyCode==KeyEvent.KEYCODE_BACK){
			backDialog();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
	private void backDialog(){
		 AlertDialog.Builder builder = new AlertDialog.Builder(MainConsumerActivity.this);
	        builder.setTitle("警告！");
	        builder.setMessage("确认退出吗？");
	        builder.setPositiveButton("确认", new DialogInterface.OnClickListener(){
	            @Override
	            public void onClick(DialogInterface dialog, int which){
	            	Global.loginUser=null;
	            	System.exit(0);
	            }
	        });
	        builder.setNegativeButton("取消", new DialogInterface.OnClickListener(){

				@Override
				public void onClick(DialogInterface dialog, int which) {
					
				}
	        });
	        builder.show();
	}

	
	
	
	
	
	
}
